package cn.flying.cloud.demo.endofday.steps.s1000;

import cn.flying.cloud.base.common.utils.Ft;
import cn.flying.cloud.task.entity.CpApplicationInfo;
import cn.flying.cloud.task.service.CpApplicationInfoService;
import org.springframework.batch.core.StepContribution;
import org.springframework.batch.core.scope.context.ChunkContext;
import org.springframework.batch.core.step.tasklet.Tasklet;
import org.springframework.batch.repeat.RepeatStatus;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.time.LocalDate;
import java.time.LocalDateTime;

/**
 * 
 * @author: admin
 * @date: 2024年01月11日 15:11
 * @version: 1.0
 */
@Component
public class DemoTasklet1 implements Tasklet {

    @Resource
    private CpApplicationInfoService applicationInfoService;

    @Override
    public RepeatStatus execute(StepContribution stepContribution, ChunkContext chunkContext) throws Exception {
        System.out.println("执行DemoTasklet1");
        for (int i = 0; i < 20; i++) {
            CpApplicationInfo applicationInfo = new CpApplicationInfo();
//            applicationInfo.setId(0L);
            applicationInfo.setAppNo(Ft.DateTime.formatLocalDateTime(LocalDateTime.now(), Ft.DateTime.DATE_TIME_FORMAT_2) + i);
            applicationInfo.setName("张三" + (i + 1));
            applicationInfo.setGender("男");
            applicationInfo.setAge(25);
            applicationInfo.setBirthday(LocalDate.now());
            applicationInfo.setNationality("中国");
            applicationInfo.setCreatedBy("system");
            applicationInfo.setCreatedTime(LocalDateTime.now());
            applicationInfo.setUpdatedBy("system");
            applicationInfo.setUpdatedTime(LocalDateTime.now());
            applicationInfo.setTenantId("10000");
            applicationInfo.setRevision(0L);
//            applicationInfo.setDeleted("");

            applicationInfoService.createObj(applicationInfo);
        }
        return RepeatStatus.FINISHED;
    }
}
